<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | Author: create by allen.qiang
// +----------------------------------------------------------------------

/**
 * 财务对账操作功能
 *
 * @package 	htdocs
 * @subpackage  quanliadmin
 * @author  	create by allen.qiang
 */


quanli_require('module/base/system/itemHandler.class.php');
quanli_require('module/base/system/sysPayment.class.php');

class pa_financialReconciliation {

    public function execute() {
        global $G_PGLOB ;
        if (isset($_REQUEST['operFlg'])) {

            switch($_REQUEST['operFlg']) {

                case 1: //财务对账
                    $this->financialReconciliationList();
                    break;
                default:
                    $G_PGLOB->smarty->assign('error_msg', '参数错误，请审核后再操作');
                    $G_PGLOB->smarty->display('comm/error.tpl');
            }
        }
    }

    /**
     * 财务对账
     */
    private function financialReconciliationList() {

        global $G_PGLOB;

        //实例化支付方式类
        $sysPayment = new sysPayment($G_PGLOB->DBCA);

        $arg_array = array();

        //查询支付方式
        $pay_ment_array = $sysPayment->searchPaymentMethod($arg_array);

        $G_PGLOB->smarty->assign('pay_ment_array', $pay_ment_array);
        $G_PGLOB->smarty->assign('edit_permission', $G_PGLOB->has_permission(20511));
        $G_PGLOB->smarty->assign('currentDate',$G_PGLOB->sys_date);//当前日期

        $table_id = 7;

        $flex_array = array(
            array('display' => '操作','width' => 180,'align' => 'center'),
            array('display' => '配送站', 'width' => 150,'align' => 'center'),
            array('display' => '订单号', 'width' => 130),
            array('display' => '配送日期','width' => 100,'align' => 'center'),
            array('display' => '配送对账','width' => 100,'align' => 'center'),
            array('display' => '财务对账','width' => 100,'align' => 'center'),
            array('display' => '配送员','width' => 100,'align' => 'center','name'=>'distribution_technician_id','sortable' => true),
            array('display' => '应收金额(现金)','width' => 100),
            array('display' => '应收金额(刷卡)','width' => 100),
            array('display' => '已回款金额(现金)','width' => 100),
            array('display' => '已回款金额(刷卡)','width' => 100),
            array('display' => '未回款金额(现金)','width' => 100),
            array('display' => '未回款金额(刷卡)','width' => 100),
        ); //flexigrid插件表格  end

        quanli_require('module/base/system/sysFlexigridLog.class.php');

        $sysFlexigridLog = new sysFlexigridLog();

        $arg_array = array(
            'table_id' => $table_id,
            'userID' => $G_PGLOB->currentUserID,
            'sortname' => 'last_cid',
            'sortorder' => 'ASC'
        );
        $flexigrid_array = $sysFlexigridLog->searchFlexigridInfo($arg_array);

        if($flexigrid_array){
            $flex_array = $flexigrid_array;
        }else{
            $arg_array = array(
                'table_id' => $table_id,
                'userID' => $G_PGLOB->currentUserID,
                'data' => $flex_array
            );
            $sysFlexigridLog->editFlexigrid($arg_array);
        }

        $G_PGLOB->smarty->assign_by_ref('table_id', $table_id);
        $G_PGLOB->smarty->assign_by_ref('fixed_json', json_encode($flex_array));

        $G_PGLOB->smarty->display('send/financialReconciliationList.tpl');
    }

}